<?php

class User_EstatController extends Zend_Controller_Action
{

    public function init()
    {
        $mail = $this->_getParam('mail', NULL);
        $token = $this->_getParam('token', NULL);
        $res = 0;
        if(is_null($mail) || is_null($token)){
            $res = -1;
            echo Zend_Json_Encoder::encode("-1");
        } else {
            $model_auth = new User_Model_AuthUsers();
            $auth = $model_auth->checkToken($mail,$token); 
            
            if($auth != 0)  echo Zend_Json_Encoder::encode("-4");
        }

        if($res == -1 || $auth != 0){
            exit;
        }
    }

    public function indexAction()
    {
        // action body
    }
    
    public function getAction(){
        $id = $this->_getParam('id', NULL);
        if(is_null($id)){
            $res = -1;
        } else {
            $model_estat = new User_Model_Estat();
            if($model_estat->get_dades($id, $nom, $posX, $posY)){
                $res = array($posX, $posY, $nom);
            } else {
                $res = -2;      // No existeix el taxista $id
            }
            
        }
        echo Zend_Json_Encoder::encode($res);
        exit;
    }


}

